const utils = require('./utils/main')
const express = require('express')
const app = express()
const path = require('path')

// 解析post请求body
app.use(express.json())
    // 公共路径
app.use(express.static('./public'))

/**
 * 各类路由
 */

// 页面路由
const page_router = require('./routers/page')
app.use('/', page_router)

// 数据路由
const data_router = require('./routers/data')
app.use('/data', data_router)



const server = app.listen(8080, '0.0.0.0', () => {
    let ipv4 = utils.getIpv4()
    let port = server.address().port

    console.log('Service listen on:')
    console.log(` - Local: http://127.0.0.1:${port}`)
    console.log(` - Network: http://${ipv4}:${port}`)
})